/**
 * @author:linjiye
 * @date: 2024/01/14
 * @desc: AI原创模块接口定义
 **/

import {createApi} from "@reduxjs/toolkit/query/react";
import useBaseQuery from "@/hooks/useBaseQuery";
import { stringify } from "qs";

export const keywordExplosionApi = createApi({
    reducerPath:'keywordExplosionApi',
    baseQuery:useBaseQuery('mm'),
    tagTypes:['queryListByUser','targetList'],
    endpoints(build) {
        return {
            // http:/192.168.200.122:3200/jeecgboot'mm/mmObserveTargetGroup/queryListByUser?targetType=2&_t=1737783278505
            queryListByUser:build.query({
                query:(data:any) => {
                    return {
                        url: 'mmObserveTargetGroup/queryListByUser',
                        method:"get",
                        params:data,
                        openErrMessage: true
                    }
                },
                providesTags: ['queryListByUser'],
            }),
            // http:/192.168.200.122:3200/jeecgboot/'mm/mmObserveTarget/list?pageNo=1&pageSize=1000&groupld=&sourcePlatform=&targetType=28 t=1737783278681
            mmObserveTargetList:build.query({
                query:(data:any) => {
                    return {
                        url: 'mmObserveTarget/list',
                        method:"get",
                        params:data,
                        openErrMessage: true
                    }
                },
                providesTags: ['targetList'],
            }),
            addKeywordGroup:build.mutation({
                query:(data:any) => {
                    return {
                        url: 'mmObserveTargetGroup/add',
                        method:"post",
                        body:data,
                        openErrMessage: true
                    }
                },
                invalidatesTags: ['queryListByUser'],
            }),
            editKeywordGroup:build.mutation({
                query:(data:any) => {
                    return {
                        url: 'mmObserveTargetGroup/edit',
                        method:"post",
                        body:data,
                        openErrMessage: true
                    }
                },
                invalidatesTags: ['queryListByUser'],
            }),
            deleteKeywordGroup:build.mutation({
                query:(data:any) => {
                    return {
                        // url: 'mmObserveTargetGroup/delete',
                        url: 'mmObserveTargetGroup/deleteBatch?ids='+data.ids,
                        method:"delete",
                        openErrMessage: true
                    }
                },
                invalidatesTags: ['queryListByUser'],
            }),
            // http:/192.168.200.122:3200/jeecgbootmm/mmObservelargetGroup/delete?id=1883075386428919809
            addKeyword:build.mutation({
                query:(data:any) => {
                    return {
                        url: 'mmObserveTarget/add',
                        method:"post",
                        body:data,
                        openErrMessage: false
                    }
                },
                invalidatesTags: ['targetList'],
            }),
            // http:/192168.200.122:3200/jeecgbootmm/'mmObserveTarget/add
            editKeyword:build.mutation({
                query:(data:any) => {
                    return {
                        url: 'mmObserveTarget/edit',
                        method:"post",
                        body:data,
                        openErrMessage: true
                    }
                },
                invalidatesTags: ['targetList'],
            }),
            deleteKeyword:build.mutation({
                query:(data:any) => {
                    return {
                        url: 'mmObserveTarget/deleteBatch?ids='+data.ids,
                        method:"delete",
                        openErrMessage: true
                    }
                },
                invalidatesTags: ['targetList'],
            }),
            groupingKeyword:build.mutation({
                query:(data:any) => {
                    return {
                        url: 'mmObserveTarget/grouping',
                        method:"put",
                        body:data,
                        openErrMessage: true
                    }
                },
            }),
            // http://192.168.200.122:3200/jeecgboot/mm/mmObserveVideo/list?targetType=2&targetId=&title=&itemCreateTime_begin=&itemCreateTime_end=&pageNo=1&pageSize=20&column=diggCount&order=asc&_t=1737831451341
            getList:build.query({
                query:(data:any) => {
                    return {
                        url: 'mmObserveVideo/list',
                        method:"get",
                        params:data,
                        openErrMessage: true
                    }
                },
            }),
        }
    }
});

export const {
    useQueryListByUserQuery,
    useMmObserveTargetListQuery,
    useAddKeywordGroupMutation,
    useEditKeywordGroupMutation,
    useDeleteKeywordGroupMutation,
    useAddKeywordMutation,
    useEditKeywordMutation,
    useDeleteKeywordMutation,
    useGroupingKeywordMutation,
    useGetListQuery,
} = keywordExplosionApi;
